package ezcaptcha

import "github.com/imroc/req/v3"

type TaskTypeCloudFlareTurnstileC string

const TaskTypeCloudFlareTurnstileCDefault TaskTypeCloudFlareTurnstileC = "CloudFlareTurnstileTask"

type TaskCloudFlareTurnstileCRQData struct {
	MetadataAction string `json:"metadataAction,omitempty"`
	MetadataCdata  string `json:"metadataCdata,omitempty"`
}

// TaskCloudFlareTurnstileC https://ezcaptcha.atlassian.net/wiki/spaces/IS/pages/331513887/CloudFlareTurnstile
type TaskCloudFlareTurnstileC struct {
	Type       TaskTypeCloudFlareTurnstileC   `json:"type"`
	WebsiteURL string                         `json:"websiteURL"`
	WebsiteKey string                         `json:"websiteKey"`
	Proxy      string                         `json:"proxy,omitempty"`
	RQData     TaskCloudFlareTurnstileCRQData `json:"rqData,omitzero"`
}

// TaskCloudFlareTurnstileR https://ezcaptcha.atlassian.net/wiki/spaces/IS/pages/331513887/CloudFlareTurnstile
type TaskCloudFlareTurnstileR struct {
	Token string `json:"token"`
}

type (
	ClientCloudFlareTurnstile  = Client[TaskCloudFlareTurnstileC, TaskCloudFlareTurnstileR]
	OptionsCloudFlareTurnstile = Option[TaskCloudFlareTurnstileC, TaskCloudFlareTurnstileR]
)

func NewClientForCloudFlareTurnstile(httpClient *req.Client, clientKey string,
	opts ...OptionsCloudFlareTurnstile) *ClientCloudFlareTurnstile {
	return NewClient(httpClient, clientKey, opts...)
}
